﻿using M_Process.API.Appliction.Command.ProductionProcessCommand;
using M_Process.Domain;
using M_Process.Repository.ProcessInterface;
using MediatR;

namespace M_Process.API.Appliction.CommandHandlers.ProductionProcessCommandHandler
{
    /// <summary>
    /// 反填充工艺过程命令处理器
    /// </summary>
    public class ReverseFillingProductionProcessCommandHandler : IRequestHandler<ReverseFillingProductionProcessCommand, ProductionProcess>
    {
        /// <summary>
        /// 工序仓储接口
        /// </summary>
        protected readonly IProductionProcessRepository productionProcessRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="productionProcessRepository">工序仓储接口</param>
        public ReverseFillingProductionProcessCommandHandler(IProductionProcessRepository productionProcessRepository)
        {
            this.productionProcessRepository = productionProcessRepository;
        }

        /// <summary>
        /// 处理反填充工艺过程命令
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ProductionProcess> Handle(ReverseFillingProductionProcessCommand request, CancellationToken cancellationToken)
        {
            return await productionProcessRepository.GetModelsAsync(request.ProductionProcessesId);
        }
    }
}
